﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace firstCodeFirstApp
{
    public class Context : DbContext
    {
        public Context()
            : base("name=firstCodeFirstApp")
        {

        }

        public DbSet<Donator> Donators { get; set; }

        public DbSet<PayWay> PayWays { get; set; }

        public DbSet<DonatorType> DonatorTypes { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new DonatorMap());
            modelBuilder.Configurations.Add(new DonatorTypeMap());

            modelBuilder.Configurations.Add(new StudentMap());
            modelBuilder.Configurations.Add(new PersonMap());

            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
            modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();

            

            base.OnModelCreating(modelBuilder);

        }

        public DbSet<Student> Students { get; set; }
        public DbSet<Person> People { get; set; }

        public DbSet<Company> Companies { get; set; }
    }
}
